<script type="text/javascript">
var paging = new function(){
	
	this.prePage = function(){
		var val = parseInt("${pageIndex}");
		if(val <= 1){
			val = 1;
		}else{
			val = val -1;;
		}
		paging.gotoPage(val);
	};
	
	this.nextPage = function(){
		var val = parseInt("${pageIndex}");
		var pageCount = parseInt( "${pageCount}");
		if(val >= pageCount){
			val = pageCount;
		}else{
			val = val + 1;
		}
		paging.gotoPage(val);
	};
	
	this.gotoPage = function(index){
		
		var iIndex = parseInt(index);
		var pageCount = parseInt( "${pageCount}");
		var $val = document.getElementById("pageIndex");
		
		if(isNaN(index) || iIndex < 1){
			$val.value =1;
		}else if(iIndex > pageCount){
			$val.value = pageCount;
		}else {
			$val.value = iIndex;
		}
		
		${function};
	};
}
</script>
<form id="${formId}" class="pagination pagination-centered" style="margin:0"  method="post">
<ul>
        <#if (totalCount > 0)>
        		<li class="disabled"><a href="#">共<strong class="text-muted">${pageCount}</strong>页</a></li>
				<#if pageIndex <= 1>
					<li class="disabled"><span>&laquo;</span></li>
				<#else>
					<li ><a onclick="paging.prePage()" href="javascript:void(0); " >&laquo;</a></li>
				</#if>
				<#if 1 == pageIndex>
					<li class="active">
						<span>1</span>
					</span>
					</li>
				<#else>
					<li ><a onclick="paging.gotoPage(1)" href="javascript:void(0);" >1</a></li>
				</#if>
			<#if ((pageIndex-2) > 2) >
					<li class="disabled"><span>...</psan></li>
			</#if>
			<#list (pageIndex-2)..(pageIndex+2) as p>
				<#if (p > 1 && p < pageCount)>
					<#if p == pageIndex>
						<li class="active">
				  			<span>${p}</span>
						</li>
					<#else>
						<li class="active">
				 		 <a onclick="paging.gotoPage(${p})" href="javascript:void(0);" >
							${p}
						  </a>
						</li>
					</#if>

				</#if>
			</#list>
			<#if ((pageIndex+2) < (pageCount-1)) >
					<li class="disabled"><span>...</span></li>
			</#if>
			<#if (pageCount > 1) >
						<#if pageCount == pageIndex >
							<li class="active">
								<span>${pageCount}</span>
							</li>
						<#else>
							<li>
								<a onclick="paging.gotoPage(${pageCount})" href="javascript:void(0);" >
									${pageCount}
								</a>
							</li>
						</#if>

			</#if>
			<#if (pageIndex >= pageCount)>
				<li class="disabled"><span>&raquo;</span></li>
			<#else>
				<li><a onclick="paging.nextPage()" href="javascript:void(0);" >&raquo;</a></li>
			</#if>
			<li class="disabled"><span>共<strong class="text-muted">${totalCount}</strong>条</span></li>
		<#else>
            <li class="disabled"><span><strong class="text-danger">无数据!</strong></span></li>
		</#if>
</ul>
<input type="hidden" id ="pageIndex" name="pageIndex" value="${pageIndex}">
<input type="hidden" id ="pageSize" name="pageSize" value="${pageSize}">
</form>
